#!/bin/bash

# 快速AI代码commit脚本
# 使用方法: ./scripts/quick-commit.sh "commit message"

set -e

# 颜色定义
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
RED='\033[0;31m'
NC='\033[0m'

# 检查参数
if [ $# -eq 0 ]; then
    echo -e "${RED}错误: 请提供commit信息${NC}"
    echo "使用方法: $0 \"commit message\""
    exit 1
fi

COMMIT_MSG="$1"

# 检查是否有更改
if [ -z "$(git status --porcelain)" ]; then
    echo -e "${YELLOW}没有检测到任何更改${NC}"
    exit 0
fi

# 添加所有更改
git add .

# 生成AI标识的commit信息
AI_COMMIT_MSG="$COMMIT_MSG

🤖 AI-GENERATED CODE - REQUIRES CAREFUL REVIEW 🤖
⚠️  REVIEWER ATTENTION REQUIRED ⚠️
- Please carefully review all AI-generated code
- Check for security vulnerabilities
- Verify business logic correctness
- Ensure code follows project standards

📊 Metadata:
- Branch: $(git branch --show-current)
- Files: $(git diff --cached --name-only | wc -l)
- Time: $(date '+%Y-%m-%d %H:%M:%S')"

# 执行commit
echo "$AI_COMMIT_MSG" | git commit -F -

echo -e "${GREEN}✓ AI代码已提交，请通知reviewer仔细review${NC}" 